Blog

Luis Majano

December 15, 2008

Spread the word


Share your thoughts

The new Transfer Loader interceptor in the up-coming ColdBox 2.6.2 will provide you with a very easy way to configure Transfer ORM in your application and use it from ColdSpring or LightWire. How easy? This easy? Open your coldbox configuration file and try to add the following, of course season to your own taste: /${Setting: AppMapping not found}/config/transfer.xml.cfm /${Setting: AppMapping not found}/config/definitions blogDSN For those who are wondering what ${Setting: AppMapping not found} means, it means that in ColdBox 2.6.2 you can re-use ANY setting within other settings and interceptor properties, much like how you do ${} replacements in ColdSpring and Lightwire, but on the coldbox.xml. This will create the transfer factory, transfer and the transfer transaction objects in the ColdBox Cache with the following case SENSITIVE keys:

  • Transfer
  • TransferFactory
  • TransferTransaction

That's it, you know can use Transfer in your application by autowiring your objects with it: Now, what happens if you want to also use coldspring or lightwire in your application for all your model objects instead of the ColdBox's default model integration (2.6.2)? Well, you still can, by using factory beans.  What are factory beans? Factory beans are objects you define in your coldspring or lightwire definitions that can produce objects for you.  So we can declare a bean to be a CarFactory that can produce different types of cars for you.  This way, coldpsring or lightwire do NOT create these objects, but they only request them.  These factories take care of creating them for you.  This is incrediblly useful, for use cases such as the one presented here, where Transfer has already been produced and is just waiting to be used. So let's start with the global XML declaration that both coldspring and lightwire can use: Transfer TransferTransaction WOW!! That simple, we just declare the ColdBox Cache Manager to be a factory bean and then we declare beans by calling methods on it with arguments, which in our case is the key to the objects in the cache. How cool is that!! You can basically wire up anything from the ColdBox Cache into any coldspring or ligthwire managed bean. The equivalent of the XML notation in LightWire's configuration object is the following (Please note that this uses the ColdBox version of Lightwire): //Define the ColdBox Factory addSingleton("coldbox.system.extras.ColdboxFactory","ColdBoxFactory"); //Define the ColdBox Cache as a Bean addSingletonFromFactory("ColdBoxFactory","getColdBoxOCM","ColdBoxCache"); //Define Transfer addSingletonFromFactory("ColdBoxCache","get","transfer"); addConstructorProperty("transfer","objectKey","Transfer"); //Define The TransferTransaction addSingletonFromFactory("ColdBoxCache","get","TransferTransaction"); addConstructorProperty("TransferTransaction","objectKey","TransferTransaction"); There you go, a programmatic approach of defining beans. So to finalize, we where able to use ANY coldbox cached element in our coldspring or lightwire object factories by leveraging factory beans. An the best use case was using the Trasnfer Loader interceptor. Enjoy!

Add Your Comment

(2)

Dec 15, 2008 19:59:39 UTC

by Aaron

I am using this approach and I love it!!!!! Thanks Luis

Jan 05, 2009 11:40:36 UTC

by Daniel

In a handler I don't find transfer in the instance scope.... I folowed your example with coldspring

Recent Entries

Must-See ITB 2025 Sessions for TestBox Users!

Must-See ITB 2025 Sessions for TestBox Users!

Are you a fan of TestBox or looking to level up your testing game in 2025? Whether you're just getting started with unit testing or you're already building advanced specs for ColdBox and BoxLang apps, Into the Box 2025 has an exciting lineup tailored just for you. Into the Box 2025 has an exciting lineup tailored just for you. With the recent launch of TestBox 6.3.0 we have amazing new tools, features and tips and tricks to get your testing experience to the next level, review our sessions and test like a pro efficiently and easy!

From hands-on testing strategies to BoxLang innovations, here are the sessions you won’t want to miss this May — and why they matter to you as a TestBox user.

Maria Jose Herrera
Maria Jose Herrera
April 17, 2025
The Into the Box 2025 Agenda is LIVE and Done!

The Into the Box 2025 Agenda is LIVE and Done!

The wait is over! The official Into the Box 2025 agenda is now live — and it's packed with high-impact sessions designed for modern CFML and BoxLang developers. Whether you’re building APIs, modernizing legacy apps, diving into serverless, or exploring AI integrations, this is the conference you’ve been waiting for.

Here’s a look at what you can expect — categorized by key topics to help you plan your learning journey, there’s something for everyone covering modern CFML tools and BoxLang:

Maria Jose Herrera
Maria Jose Herrera
April 15, 2025
Only 2 Days Left to Lock In Early Bird Pricing for Into the Box 2025!

Only 2 Days Left to Lock In Early Bird Pricing for Into the Box 2025!

The countdown is on. You have just two days left to secure your Early Bird ticket  for just $199 to Into the Box 2025 before prices increase on April 16.

We are proud to offer an engaging and high-value online experience for developers around the world. With a virtual ticket, you get more than just access — you get ongoing value that supports your growth long after the conference ends.

Maria Jose Herrera
Maria Jose Herrera
April 14, 2025